from typing import *


class Solution:
    def minBitwiseArray(self, nums: List[int]) -> List[int]:
        ans = [-1] * len(nums)

        def f(num):
            if num == 2:
                return -1
            tail = num ^ (num + 1)
            return num >> (tail.bit_length() - 1) << (tail.bit_length() - 1) | (
                (1 << (tail.bit_length() - 2)) - 1
            )

        for i, v in enumerate(nums):
            ans[i] = f(v)
        return ans


so = Solution()
print(so.minBitwiseArray([2, 3, 5, 7, 11]))
